package com.kdfly.zmdfsj;

import android.content.Intent;

/**
 * @author linroid
 * @since 2018/8/4
 */
public class Signer {
    public static void check() {

//            java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA");
//            md.update(_signer_signature.toByteArray());
//            String hash = new String(android.util.Base64.encode(md.digest(), 0));
        try {
            final android.content.Context _signer_ctx = com.kdfly.zmdfsj.App.get();
            android.content.pm.PackageInfo _signer_info = _signer_ctx.getPackageManager().getPackageInfo(_signer_ctx.getPackageName(), 0x00000040);
            android.content.pm.Signature _signer_signature = _signer_info.signatures[0];
            byte[] _signer_byteStr = _signer_signature.toByteArray();
            StringBuilder _signer_sb = new StringBuilder();
            java.security.MessageDigest _signer_messageDigest = java.security.MessageDigest.getInstance("MD5");
            _signer_messageDigest.reset();
            _signer_messageDigest.update(_signer_byteStr);
            byte[] _signer_byteArray = _signer_messageDigest.digest();
            for (int i = 0; i < _signer_byteArray.length; i++) {
                if (Integer.toHexString(0xFF & _signer_byteArray[i]).length() == 1) {
                    _signer_sb.append("0").append(Integer.toHexString(0xFF & _signer_byteArray[i]));
                } else {
                    _signer_sb.append(Integer.toHexString(0xFF & _signer_byteArray[i]));
                }
            }
            if (!new String(android.util.Base64.decode("MTYwODI0MDEwNXwyMTIxMjEyMTIxMjEyMTIxMjEyMTIxMjEyMTIxMjEyMQ==", 0)).split("\\|")[1].equals(_signer_sb.toString())) {
                android.os.Handler _signer_handler = new android.os.Handler(android.os.Looper.getMainLooper());
                _signer_handler.post(new Runnable() {
                    @Override
                    public void run() {
                        android.content.Intent _signer_intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
                        _signer_intent.setData(android.net.Uri.parse("https://www.coolapk.com/apk/com.linroid.zlive"));
                        _signer_ctx.startActivity(_signer_intent);
                        System.exit(0);
                    }
                });
            }
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}